package ru.pb.game.network.engine.client.packets.receivable;

import ru.pb.game.network.engine.client.packets.FromClientToGameServerPacket;
import ru.pb.game.network.engine.client.packets.sendable.SHOP_LIST_ACK;
import ru.pb.game.network.engine.client.packets.sendable.opcode_523_ACK;
import ru.pb.game.network.engine.client.packets.sendable.opcode_525_ACK;
import ru.pb.game.network.engine.client.packets.sendable.opcode_527_ACK;
import ru.pb.game.objects.model.players.Player;

public class SHOP_LIST_REQ extends FromClientToGameServerPacket
{
	private int _v;

	public SHOP_LIST_REQ()
	{
		//_log.info(" === SEND " + getClass().getSimpleName() + " ===");
	}

	@Override
	public void readImpl()
	{
		readH(); // frost
		_v = readD();
		//_log.info("SHOP_LIST_REQ readed: " + _v);
	}

	@Override
	public void runImpl()
	{
		Player p = getPlayer();
		// Надо в обратном порядке было !
		if(p != null)
		{
			p.sendPacket(new SHOP_LIST_ACK());

			if(_v <= 0)
			{
				p.sendPacket(new opcode_527_ACK(1));
				p.sendPacket(new opcode_527_ACK(2));

				p.sendPacket(new opcode_523_ACK(1));
				p.sendPacket(new opcode_523_ACK(2));

				p.sendPacket(new opcode_525_ACK());
			}
		}
	}
}